﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DAO;

namespace TAM_SPORT
{
    public partial class Frminventory : TAM_SPORT.FormBase
    {
        private ImportDao imDao;
        public Frminventory()
        {
            InitializeComponent();
            imDao = new ImportDao();
            loadGrid();
        }

        private void loadGrid()
        {
            DataTable table = imDao.getInventory();
            dtgResult.Rows.Clear();
            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow row1 in table.Rows)
                {
                    int i = dtgResult.Rows.Add();
                    dtgResult.Rows[i].Cells[0].Value = i + 1;
                    dtgResult.Rows[i].Cells[1].Value = row1["NAME"].ToString();
                    dtgResult.Rows[i].Cells[2].Value = row1["UNIT_NAME"].ToString();
                    dtgResult.Rows[i].Cells[3].Value = Convert.ToDouble(row1["IMPORT"]).ToString("#,###.##");
                    dtgResult.Rows[i].Cells[4].Value = Convert.ToDouble(row1["EXPORT"]).ToString("#,###.##");
                    dtgResult.Rows[i].Cells[5].Value = Convert.ToDouble(row1["INVENTORY"]).ToString("#,###.##");
                    if (i % 2 == 1)
                    {
                        dtgResult.Rows[i].DefaultCellStyle.BackColor = Color.LightCyan;
                    }
                }
            }
        }

    }
}
